function someFunction() {
    var items1 = new Array(-20);
}

function tryCatch() {
    try {
        someFunction();
    } catch (error) {
        if (error instanceof TypeError) {
            console.log("处理类型错误");
        } else if (error instanceof ReferenceError) {
            console.log("处理引用错误");
        } else if (error instanceof EvalError) {
            console.log("EvalError");
        } else if (error instanceof RangeError) {
            console.log("RangeError");
        } else if (error instanceof SyntaxError) {
            console.log("SyntaxError");
        } else if (error instanceof URIError) {
            console.log("URIError");
        } else {
            console.log("处理其他类型的错误");
        }
    }
}

function logError(sev, msg) {
    var img = new Image();
    img.src = "log.php?sev=" + encodeURIComponent(sev) + "&msg=" +
        encodeURIComponent(msg);
}

function log(message) {
    if (typeof console == "object") {
        console.log(message);
    } else if (typeof opera == "object") {
        opera.postError(message);
    } else if (typeof java == "object" && typeof java.lang == "object") {
        java.lang.System.out.println(message);
    }
}

function logMsg(message) {
    var console = document.getElementById("debuginfo");
    if (console === null) {
        console = document.createElement("div");
        console.id = "debuginfo";
        console.style.background = "#dedede";
        console.style.border = "1px solid silver";
        console.style.padding = "5px";
        console.style.width = "400px";
        console.style.position = "absolute";
        console.style.right = "0px";
        console.style.top = "0px";
        document.body.appendChild(console);
    }
    console.innerHTML += "<p>" + message + "</p>";
}

function logMsgTest() {
    logMsg("日志测试");
}
function assert(condition, message){
    if (!condition){
        throw new Error(message);
    }
}
tryCatch();